<template>
  <el-drawer
    :visible.sync="$store.state.process.flyNoticeDrawer"
    :with-header="false"
    :before-close="beforeClose"
    size="680px"
    @open="openDrawer">
    <div class="title">
      <Title title="节点设置" />
      <i class="icon el-icon-close" @click="beforeClose()"/>
    </div>
    <div class="content">
      <div v-for="(roleItem, index) in flyNoticeDrawerData.examineRoles" :key="index">
        <el-input v-model="roleItem.roleName" :maxlength="16" placeholder="输入角色名称" size="small" class="width-240" />
      </div>
    </div>
  </el-drawer>
</template>

<script>
import { mapState } from 'vuex';
import Title from '@/components/Title';
import ElMessage from '@/utils/message';
export default {
  components: { Title },
  data() {
    return {

    };
  },
  computed: {
    ...mapState({
      'flyNoticeDrawerData': state => state.process.flyNoticeDrawerData
    })
  },
  methods: {
    beforeClose(done) {
      const examineRoles = this.flyNoticeDrawerData.examineRoles;
      if (!examineRoles || examineRoles.length === 0 || !examineRoles[0].roleName) {
        ElMessage.error('请输入角色名称');
        return;
      }
      this.$store.commit('SET_FLYNOTICE_DATA', {});
      this.$store.commit('SET_FLYNOTICE_SWITCH', false);
      done && done();
    },
    openDrawer() {
      const examineRoles = this.flyNoticeDrawerData.examineRoles;
      if (!examineRoles || examineRoles.length === 0 || !examineRoles[0].roleName) {
        this.$set(this.flyNoticeDrawerData, 'examineRoles', [{ roleName: '', roleType: 11 }]);
      }
    }
  }
};
</script>

<style lang="scss" scoped>
.content {
  padding: 17px 20px;
}
.title {
  display: flex;
  height: 50px;
  padding: 0 24px;
  align-items: center;
  border-bottom: 1px solid #f5f5f5;
  .icon {
    font-size: 18px;
    color: #999;
    cursor: pointer;
  }
}
.width-240 {
  width: 240px;
  &::v-deep {
    .el-input__inner {
      width: 240px;
    }
  }
}

</style>
